import { Schema, SchemaTypes } from 'mongoose';
import * as bcrypt from 'bcrypt';
import config from '../config/config';
export interface AdminUser {
    _id: string;
    username: string;
    password: string;
    sex: number;
}
export const AdminSchema = new Schema(
    {
        username: {
            type: String,
            required: true,
        },
        password: {
            type: String,
            required: true,
            set(value) {
                return bcrypt.hashSync(value, 10); //加密级别：10-12
            },
            select: false,
        },
        status: {
            type: Number,
            default: 1,
            enum: [0, 1],
        },
        sex: {
            type: Number,
            default: 1,
            enum: [0, 1, 2], //0:女,1:男,2:保密
        },
        role_id: {
            type: SchemaTypes.ObjectId,
        },
        mobile: Number,
        email: String,
        is_super: Number,
        avatar: String,
    },
    config.SchemaOptions,
);
